package com.fuint.base.shiro.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import com.fuint.base.shiro.interceptor.ShiroInterceptor;
import com.fuint.interceptor.SiteHandlerInterceptor;

/**
 * 设置拦截器,填充shiro user 信息
 * 
 * 
 */
@Configuration
public class ShiroAdapter extends WebMvcConfigurerAdapter {
	
	@Autowired
	private SiteHandlerInterceptor handlerInterceptor;
	
	@Autowired
	private ShiroInterceptor shiroInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
    	registry.addInterceptor(handlerInterceptor)
    		.addPathPatterns("/**")
    		.excludePathPatterns("/assets/**")
    		.excludePathPatterns("/css/**")
    		.excludePathPatterns("/defaultImage/**")
    		.excludePathPatterns("/img/**")
    		.excludePathPatterns("/js/**")
    		.excludePathPatterns("/uploadImages/**");
        registry.addInterceptor(shiroInterceptor)
        	.addPathPatterns("/**")
    		.excludePathPatterns("/assets/**")
    		.excludePathPatterns("/css/**")
    		.excludePathPatterns("/defaultImage/**")
    		.excludePathPatterns("/img/**")
    		.excludePathPatterns("/js/**")
    		.excludePathPatterns("/uploadImages/**");
    }
}
